package io.lkt.modules.sys.service.impl;

import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import io.lkt.commons.dynamic.datasource.annotation.DataSource;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.lkt.common.utils.PageUtils;
import io.lkt.common.utils.Query;

import io.lkt.modules.sys.dao.BBusinessLecturerDao;
import io.lkt.modules.sys.entity.BBusinessLecturerEntity;
import io.lkt.modules.sys.service.BBusinessLecturerService;

import javax.annotation.Resource;


@Service("bBusinessLecturerService")
public class BBusinessLecturerServiceImpl extends ServiceImpl<BBusinessLecturerDao, BBusinessLecturerEntity> implements BBusinessLecturerService {
    @Resource
    BBusinessLecturerDao bBusinessLecturerDao;

    @Override
    @DataSource("master")
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<BBusinessLecturerEntity> page = this.page(
                new Query<BBusinessLecturerEntity>().getPage(params),
                new QueryWrapper<BBusinessLecturerEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    @DataSource("master")
    public List<BBusinessLecturerEntity> queryAll() {
        return bBusinessLecturerDao.queryAll();
    }

    @Override
    @DataSource("master")
    public BBusinessLecturerEntity queryOne(BBusinessLecturerEntity bBusinessLecturer) {
        return bBusinessLecturerDao.queryOne(bBusinessLecturer);
    }

    @Override
    @DataSource("master")
    public BBusinessLecturerEntity getById(Serializable id)
    {
        return (BBusinessLecturerEntity)((BBusinessLecturerDao)this.baseMapper).selectById(id);
    }

    @Override
    @DataSource("master")
    public boolean save(BBusinessLecturerEntity entity)
    {
        return retBool(Integer.valueOf(((BBusinessLecturerDao)this.baseMapper).insert(entity)));
    }

    @Override
    @DataSource("master")
    public boolean updateById(BBusinessLecturerEntity entity)
    {
        return retBool(Integer.valueOf(((BBusinessLecturerDao)this.baseMapper).updateById(entity)));
    }

    @Override
    @DataSource("master")
    public boolean removeByIds(Collection<? extends Serializable> idList) {
        return SqlHelper.delBool(this.baseMapper.deleteBatchIds(idList));
    }

}
